//
// Created by hrg on 2019/11/23.
//

#ifndef RESTRUCTURE_MASTER_H
#define RESTRUCTURE_MASTER_H

#include <cstdint>
#include <ecrt.h>

class Master{
public:
    Master(uint32_t index = 0);
    ~Master();

    bool Init();
    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    bool Config(ec_slave_config_t* slave_conf, int interval);

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    bool CheckLinkStatus();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    bool StartMaster();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    ec_master_t* GetMaster();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    int GetSlvNum();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    ec_domain_t* GetDomain();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    uint8_t *GetDomainData();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    void RecvFrame();

    bool CheckSlaveState();

    /**
     * @Func
     * @Berif
     * @Input
     * @Output
     */
    void SendFrame();
private:
    uint32_t m_Index_;

    ec_domain_t *m_Domain_;
    ec_master_t *m_Master_;
    uint8_t *m_DomainPtr_;

    ec_master_state_t currstate_;
    ec_master_info_t m_MasterInfo_;
};

#endif //RESTRUCTURE_MASTER_H
